{if $action == 'my'}
{template 'header-widget', $module}
<form action="friend.php">
<input type="hidden" name="action" value="{$action}"/>
<input type="hidden" name="from" value="{$from}"/>
<div class="tt">
{$fields_select}&nbsp;
<input type="text" size="40" name="kw" value="{$kw}" title="关键词"/>&nbsp;
<input type="submit" value="搜 索" class="btn"/>
<input type="button" value="重 搜" class="btn" onclick="Go('friend.php?action={$action}&from={$from}');"/>
</div>
</form>
{if $lists}
<div class="ls">
<table cellpadding="0" cellspacing="0" class="tb">
<tr>
<th width="26"></th>
<th>公司</th>
<th>姓名</th>
<th>{if $from=='sms'}手机{else}会员{/if}</th>
{if $DT[im_web]}<th>在线</th>{/if}
<th><input type="checkbox" id="c_0" onclick="_check();"/></th>
</tr>
{loop $lists $k $v}
<tr onmouseover="this.className='on';" onmouseout="this.className='';" align="center" title="{$v[note]}">
<td><img src="{useravatar($v[username], 'small')}" width="20"/></td>
<td align="left">&nbsp;<a href="{userurl($v[username])}" target="_blank" class="t">{$v[company]}</a></td>
<td>{$v[truename]}</td>
<td id="v_{$v[itemid]}">{if $from=='sms'}{$v[mobile]}{else}{$v[username]}{/if}</td>
{if $DT[im_web]}<td>{im_web($v[username])}</td>{/if}
<td><input type="checkbox" id="c_{$v[itemid]}" onclick="_send({$v[itemid]});"/></td>
</tr>
{/loop}
</table>
</div>
{if $page}<div class="pages">{$pages}</div>{/if}
<div style="text-align:center;">
<input type="button" value="确 定" class="btn" onclick="window.parent.cDialog();"/>&nbsp;&nbsp;
<input type="button" value="关 闭" class="btn" onclick="window.parent.cDialog();"/>
</div>
<script type="text/javascript">
var itemids = [{loop $lists $i $t}{if $i},{/if}'{$t[itemid]}'{/loop}];
{if $from == 'sms'}
	function _send(id) {
		var v = Dd('v_'+id).innerHTML;
		if(parent.Dd('mob').value && parent.Dd('mob').value.indexOf("\n") == -1) parent.Dd('mob').value = parent.Dd('mob').value+"\n";
		if(Dd('c_'+id).checked) {
			if(parent.Dd('mob').value.indexOf(v) == -1) parent.Dd('mob').value = parent.Dd('mob').value+v+"\n";
		} else {
			if(parent.Dd('mob').value.indexOf(v) != -1) parent.Dd('mob').value = parent.Dd('mob').value.replace(v+"\n", '');
		}
	}
	function _check() {
		for(var i = 0; i < itemids.length; i++) {
			itemid = itemids[i];
			Dd('c_'+itemid).checked = Dd('c_0').checked ? true :false;
			_send(itemid);
		}
	}
	if(parent.Dd('mob').value) {
		s = parent.Dd('mob').value+"\n";
		for(var i = 0; i < itemids.length; i++) {
			itemid = itemids[i];
			f = Dd('v_'+itemid).innerHTML+"\n";
			if(s.indexOf(f) != -1) Dd('c_'+itemid).checked = true;
		}
	}
{else}
	var max = {$MOD[maxtouser]};
	function _send(id) {
		var v = Dd('v_'+id).innerHTML;
		if(parent.Dd('touser').value && parent.Dd('touser').value.indexOf(' ') == -1) parent.Dd('touser').value = parent.Dd('touser').value+' ';
		if(Dd('c_'+id).checked) {
			if(max && substr_count(parent.Dd('touser').value, ' ') >= max) {
				Dd('c_'+id).checked = false;
				return alert('最多可以选择'+max+'个收件人');
			}
			if(parent.Dd('touser').value.indexOf(v) == -1) parent.Dd('touser').value = parent.Dd('touser').value+v+' ';
		} else {
			if(parent.Dd('touser').value.indexOf(v) != -1) parent.Dd('touser').value = parent.Dd('touser').value.replace(v+' ', '');
		}
	}
	function _check() {
		for(var i = 0; i < itemids.length; i++) {
			itemid = itemids[i];
			if(Dd('c_0').checked) {
				if(max && substr_count(parent.Dd('touser').value, ' ') >= max) {
					break;
				} else {
					Dd('c_'+itemid).checked = true;
					_send(itemid);
				}
			} else {
				Dd('c_'+itemid).checked = false;
				_send(itemid);
			}
		}
	}
	if(parent.Dd('touser').value) {
		s = parent.Dd('touser').value+' ';
		for(var i = 0; i < itemids.length; i++) {
			itemid = itemids[i];
			f = Dd('v_'+itemid).innerHTML+' ';
			if(s.indexOf(f) != -1) Dd('c_'+itemid).checked = true;
		}
	}
{/if}
</script>
{else}
<center>{if $kw}未搜索到商友{else}暂无商友{/if}</center>
{/if}
</body>
</html>
{else}
{template 'header', $module}
<div class="menu">
<table cellpadding="0" cellspacing="0">
<tr>
<td class="tab" id="add"><a href="friend.php?action=add"><span>添加商友</span></a></td>
<td class="tab" id="home"><a href="friend.php?action=index"><span>我的商友</span></a></td>
<td class="tab" id="type"><a href="javascript:Dwidget('type.php?item=friend', '[商友分类]', 600, 300);"><span>商友分类</span></a></td>
</tr>
</table>
</div>
{if $action == 'add'}
<form method="post" action="friend.php" onsubmit="return check();">
<input type="hidden" name="action" value="{$action}"/>
<table cellpadding="5" cellspacing="1" class="tb">
<tr>
<td class="tl">分类</td>
<td class="tr"><span id="type_box">{$type_select}</span>&nbsp; <a href="javascript:var type_item='friend-{$_userid}',type_name='post[typeid]',type_default='{$L[default_type]}',type_id={$typeid},type_interval=setInterval('type_reload()',500);Dwidget('type.php?item=friend', '[商友分类]', 600, 300);" class="t">[管理分类]</a></td>
</tr>
<tr>
<td class="tl"><span class="f_red">*</span> 姓名</td>
<td class="tr"><input type="text" size="20" name="post[truename]" id="truename" value="{$truename}"/> {dstyle('post[style]')} <span id="dtruename" class="f_red"></span></td>
</tr>
<tr>
<td class="tl">会员名</td>
<td class="tr"><input type="text" size="20" name="post[username]" id="username" value="{$username}"/> <input type="button" class="btn_b" value="显示资料" onclick="Go('friend.php?action=add&username='+Dd('username').value);"/></td>
</tr>
<tr>
<td class="tl">公司名称</td>
<td class="tr"><input type="text" size="40" name="post[company]" id="company" value="{$company}"/></td>
</tr>
<tr>
<td class="tl">职位</td>
<td class="tr"><input type="text" size="20" name="post[career]" id="career" value="{$career}"/></td>
</tr>
<tr>
<td class="tl">电话</td>
<td class="tr"><input type="text" size="20" name="post[telephone]" id="telephone" value="{$telephone}"/></td>
</tr>
<tr>
<td class="tl">手机</td>
<td class="tr"><input type="text" size="20" name="post[mobile]" id="mobile"/></td>
</tr>
<tr>
<td class="tl">主页</td>
<td class="tr"><input type="text" size="40" name="post[homepage]" id="homepage" value="{$homepage}"/></td>
</tr>
<tr>
<td class="tl">Email</td>
<td class="tr"><input type="text" size="30" name="post[email]" id="email"/></td>
</tr>
{if $DT[im_qq]}
<tr>
<td class="tl">QQ</td>
<td class="tr"><input type="text" size="20" name="post[qq]" id="qq" value="{$qq}"/></td>
</tr>
{/if}
{if $DT[im_ali]}
<tr>
<td class="tl">阿里旺旺</td>
<td class="tr"><input type="text" size="20" name="post[ali]" id="ali" value="{$ali}"/></td>
</tr>
{/if}
{if $DT[im_msn]}
<tr>
<td class="tl">MSN</td>
<td class="tr"><input type="text" size="30" name="post[msn]" id="msn" value="{$msn}"/></td>
</tr>
{/if}
{if $DT[im_skype]}
<tr>
<td class="tl">Skype</td>
<td class="tr"><input type="text" size="20" name="post[skype]" id="skype" value="{$skype}"/></td>
</tr>
{/if}
<tr>
<td class="tl">备注</td>
<td class="tr"><input type="text" size="40" name="post[note]" id="note"/></td>
</tr>
<tr>
<td class="tl">&nbsp;</td>
<td class="tr" height="50"><input type="submit" name="submit" value=" 添 加 " class="btn_g"/></td>
</tr>
</table>
</form>
<script type="text/javascript">s('friend');m('add');</script>
{elseif $action == 'edit'}
<form method="post" action="friend.php" onsubmit="return check();">
<input type="hidden" name="action" value="{$action}"/>
<input type="hidden" name="itemid" value="{$itemid}"/>
<input type="hidden" name="forward" value="{$forward}"/>
<table cellpadding="5" cellspacing="1" class="tb">
<tr>
<td class="tl">分类</td>
<td class="tr"><span id="type_box">{$type_select}</span>&nbsp; <a href="javascript:var type_item='friend-{$_userid}',type_name='post[typeid]',type_default='{$L[default_type]}',type_id={$typeid},type_interval=setInterval('type_reload()',500);Dwidget('type.php?item=friend', '[商友分类]', 600, 300);" class="t">[管理分类]</a></td>
</tr>
<tr>
<td class="tl">显示顺序</td>
<td class="tr f_gray"><input type="text" size="3" name="post[listorder]" id="listorder" value="{$listorder}"/> 请填写数字，数字越大越靠前</td>
</tr>
<tr>
<td class="tl"><span class="f_red">*</span> 姓名</td>
<td class="tr"><input type="text" size="20" name="post[truename]" id="truename" value="{$truename}"/> {dstyle('post[style]', $style)} <span id="dtruename" class="f_red"></span></td>
</tr>
<tr>
<td class="tl">会员名</td>
<td class="tr"><input type="text" size="20" name="post[username]" id="username" value="{$username}"/></td>
</tr>
<tr>
<td class="tl">公司名称</td>
<td class="tr"><input type="text" size="40" name="post[company]" id="company" value="{$company}"/></td>
</tr>
<tr>
<td class="tl">职位</td>
<td class="tr"><input type="text" size="20" name="post[career]" id="career" value="{$career}"/></td>
</tr>
<tr>
<td class="tl">电话</td>
<td class="tr"><input type="text" size="20" name="post[telephone]" id="telephone" value="{$telephone}"/></td>
</tr>
<tr>
<td class="tl">手机</td>
<td class="tr"><input type="text" size="20" name="post[mobile]" id="mobile" value="{$mobile}"/></td>
</tr>
<tr>
<td class="tl">主页</td>
<td class="tr"><input type="text" size="40" name="post[homepage]" id="homepage" value="{$homepage}"/></td>
</tr>
<tr>
<td class="tl">Email</td>
<td class="tr"><input type="text" size="30" name="post[email]" id="email" value="{$email}"/></td>
</tr>
{if $DT[im_qq]}
<tr>
<td class="tl">QQ</td>
<td class="tr"><input type="text" size="20" name="post[qq]" id="qq" value="{$qq}"/></td>
</tr>
{/if}
{if $DT[im_ali]}
<tr>
<td class="tl">阿里旺旺</td>
<td class="tr"><input type="text" size="20" name="post[ali]" id="ali" value="{$ali}"/></td>
</tr>
{/if}
{if $DT[im_msn]}
<tr>
<td class="tl">MSN</td>
<td class="tr"><input type="text" size="30" name="post[msn]" id="msn" value="{$msn}"/></td>
</tr>
{/if}
{if $DT[im_skype]}
<tr>
<td class="tl">Skype</td>
<td class="tr"><input type="text" size="20" name="post[skype]" id="skype" value="{$skype}"/></td>
</tr>
{/if}
<tr>
<td class="tl">备注</td>
<td class="tr"><input type="text" size="40" name="post[note]" id="note" value="{$note}"/></td>
</tr>
<tr>
<td class="tl">&nbsp;</td>
<td class="tr" height="50"><input type="submit" name="submit" value=" 修 改 " class="btn_g"/>&nbsp;&nbsp;&nbsp;&nbsp;<input type="button" value=" 取 消 " class="btn" onclick="history.back(-1);"/></td>
</tr>
</table>
</form>
<script type="text/javascript">s('friend');m('home');</script>
{else}
<form action="friend.php">
<div class="tt">
&nbsp;{$fields_select}&nbsp;
<input type="text" size="50" name="kw" value="{$kw}" title="关键词"/>&nbsp;
{$type_select}&nbsp;
<input type="submit" value=" 搜 索 " class="btn"/>
<input type="button" value=" 重 搜 " class="btn" onclick="Go('friend.php');"/>
</div>
</form>
<table cellpadding="5" cellspacing="1" width="100%" bgcolor="#E8E8E8">
{loop $lists $k $v}
{if $k%2==0}<tr>{/if}
<td valign="top" width="50%" bgcolor="#FFFFFF" onmouseover="this.style.backgroundColor='#F5F5F5';" onmouseout="this.style.backgroundColor='#FFFFFF';" title="{$v[note]}">
{if $v}
<table cellpadding="2" cellspacing="2" width="96%" align="center">
<tr>
<td height="24"><strong>{$v[dcompany]}</strong></td>
</tr>
<tr>
<td height="22">{$v[truename]}{if $v[career]} ({$v[career]}){/if}</td>
</tr>
<tr>
<td height="20">电话：{$v[telephone]}</td>
</tr>
<tr>
<td height="20">手机：{$v[mobile]}</td>
</tr>
<tr>
<td height="20">
<span class="f_r" title="添加时间 {$v[adddate]}">
<a href="friend.php?typeid={$v[typeid]}" class="t">[{$v[type]}]</a>&nbsp;
<a href="?action=edit&itemid={$v[itemid]}" class="t">[修改]</a>&nbsp;
<a href="?action=delete&itemid={$v[itemid]}" onclick="return confirm('确定要删除吗？此操作将不可撤销');" class="t">[删除]</a>&nbsp;
</span>
{if $v[homepage]}<a href="{$v[homepage]}" target="_blank"><img width="16" height="16" src="{DT_SKIN}image/homepage.gif" title="公司主页" alt="" align="absmiddle"/></a>&nbsp;{/if}
{if $DT[sms] && $v[mobile]}<a href="sms.php?action=add&mob={$v[mobile]}"><img width="16" height="16" src="{DT_SKIN}image/mobile.gif" title="发送短信" align="absmiddle"/></a>&nbsp;{/if}
{if $v[username]}<a href="message.php?action=send&touser={$v[username]}"><img width="16" height="16" src="{DT_SKIN}image/msg.gif" title="发送站内信" alt="" align="absmiddle"/></a>&nbsp;{/if}
{if $v[email]}<a href="sendmail.php?email={$v[email]}"><img width="16" height="16" src="{DT_SKIN}image/email.gif" title="发送Email {$v[email]}" alt="" align="absmiddle"/></a>&nbsp;{/if}
{if $v[username] && $DT[im_web]}{im_web($v[username])}&nbsp;{/if}
{if $v[qq] && $DT[im_qq]}{im_qq($v[qq])}&nbsp;{/if}
{if $v[ali] && $DT[im_ali]}{im_ali($v[ali])}&nbsp;{/if}
{if $v[msn] && $DT[im_msn]}{im_msn($v[msn])}&nbsp;{/if}
{if $v[skype] && $DT[im_skype]}{im_skype($v[skype])}&nbsp;{/if}
</td>
</tr>
</table>
{else}
&nbsp;
{/if}
</td>
{if $k%2==1}</tr>{/if}
{/loop}
</table>
{if $MG[friend_limit]}
<div class="limit">商友上限 <span class="f_b f_red">{$MG[friend_limit]}</span> 人&nbsp;&nbsp;&nbsp;当前已加 <span class="f_b">{$limit_used}</span> 人&nbsp;&nbsp;&nbsp;还可以加 <span class="f_b f_blue">{$limit_free}</span> 人</div>
{/if}
<div class="pages">{$pages}</div>
<script type="text/javascript">s('friend');m('home');</script>
{/if}
{if $action=='add' || $action=='edit'}
<script type="text/javascript">
function check() {
	if(Dd('truename').value == '') {
		Dmsg('请填写姓名', 'truename');
		return false;
	}
	return true;
}
</script>
{/if}
{template 'footer', $module}
{/if}